import { View } from "@tarojs/components";
import { useState } from "react";
import { styled } from "@linaria/react";
import { useCallContainerGet } from "@/tools/useCallContainer";
import Taro from "@tarojs/taro";  

import TabBar from '@/components/TabBar';
import TaroMap from '@/components/Mapss';

export default function collections() {

    const [currentTab, setCurrentTab] = useState<number>(1);

    const handleTabClick = (index: number) => {
        setCurrentTab(index);
        if (index === 0) {
            Taro.redirectTo({ url: '../index/index' });
            //Taro.navigateTo({ url: '../index/index' });
        } else if (index === 1) {
            //Taro.redirectTo({ url: '../GetMapp/index' });
            //Taro.navigateTo({ url: "../restaurant/index?id=1" });
        }
        else if (index === 2) {
            Taro.redirectTo({ url: '../collections/index' });
            //Taro.navigateTo({ url: "../restaurant/index?id=1" });
        }
        else if (index === 3) {
            Taro.redirectTo({ url: "../Users/index" });
            //Taro.navigateTo({ url: "../collections/index" });
        }
        // 添加其他导航项的处理逻辑
    };
    const tabList = [
    { title: '食堂', iconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/home1.png', selectedIconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/home2.png' },
    { title: '地图', iconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/map_marker_icon.svg' , selectedIconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/map_marker_icon.svg'},
    { title: '收藏', iconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/collection1.png', selectedIconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/tabbar/collection2.png'},
    
    { title: '用户', iconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/user_circle_light_icon.png', selectedIconPath: 'cloud://prod-0g6virbea3062996.7072-prod-0g6virbea3062996-1322280255/8726547_user_circle_icon.png'},
    // 添加其他的导航项
    ];

    return (
        <View style={{ padding: "10px" ,flexDirection:"column"}}>
        
            <View style={{ width: '100%', height: '680px' }}>
                <TaroMap/>
            </View>
            <View className="container"> 
                <TabBar tabList={tabList} current={currentTab} onClick={handleTabClick} />
            </View>
        </View>
    );
}